<template>
  <el-row :gutter="10" class="panel-group">
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('newVisitis')">
        <div class="card-panel-icon-wrapper ">
          <svg-icon icon-class="000" class-name="card-panel-icon" style="font-size:90px;" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text" style="color: #333333;">
            用户数：<count-to :start-val="0" :end-val="panel.userCount" :duration="3000" class="card-panel-num" />
            <span style="font-size:14px;">(小程序：
              <count-to  style="font-size:14px;" :start-val="0" :end-val="panel.miniAppUserCount" :duration="3000" class="card-panel-num" />
              )</span>
          </div>
          
          <div class="card-panel-text" style="font-size:14px;">
                公司入驻：<count-to :start-val="0" :end-val="panel.companyCount" :duration="3000" class="card-panel-num" style="font-size:14px;" />
                <span style="margin-left:15px;"></span>
                认证人数：<count-to :start-val="0" :end-val="panel.authUserCount" :duration="3000" class="card-panel-num" style="font-size:14px;" />
          </div>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('messages')">
        <div class="card-panel-icon-wrapper ">
          <svg-icon icon-class="001" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text" style="color: #333333;">
            待接单:<count-to :start-val="0" :end-val="panel.publishOrderCount" :duration="3000" class="card-panel-num" />
            <span style="margin-left:10px;"></span> 
            <el-link v-if="roles.includes('admin') || roles.includes('platform')"
               type="primary" href="https://data.baibianlg.com" target="_blank" style="font-size:16px;font-weight: 600;">
               查看大屏<i class="el-icon-d-arrow-right"></i>
            </el-link>
          </div>
          <div class="card-panel-text" style="font-size:14px;">
            待服务:<count-to :start-val="0" :end-val="panel.receiveOrderCount" :duration="3000" class="card-panel-num" style="font-size:14px;" />
            <span style="margin-left:10px;"></span>
            服务中:<count-to :start-val="0" :end-val="panel.servingOrderCount" :duration="3000" class="card-panel-num" style="font-size:14px;" />
            <span style="margin-left:10px;"></span>
            待确认:<count-to :start-val="0" :end-val="panel.finishOrderCount" :duration="3000" class="card-panel-num" style="font-size:14px;" />
          </div>
        </div>
      </div>
    </el-col>
    
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('shoppings')">
        <div class="card-panel-icon-wrapper ">
          <svg-icon icon-class="002" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text"  style="color: #333333;">
            月订单：<count-to :start-val="0" :end-val="panel.monthOrderCount" :duration="3000" class="card-panel-num" />
            <span style="margin-left:15px;"></span>
            ￥<count-to :start-val="0" :end-val="panel.monthOrderAmount" :duration="3000" class="card-panel-num" />
          </div>
          <div class="card-panel-text" style="font-size:14px;">
            累计：<count-to :start-val="0" :end-val="panel.orderCount" :duration="3000" class="card-panel-num" style="font-size:14px;" />
            <span style="margin-left:15px;"></span>
            ￥<count-to :start-val="0" :end-val="panel.orderAmount" :duration="3000" class="card-panel-num" style="font-size:14px;" /> 
          </div>
          
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('purchases')">
        <div class="card-panel-icon-wrapper ">
          <svg-icon icon-class="003" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text" style="color: #333333;">
            待处理异常订单： <count-to :start-val="0" :end-val="panel.exOrder1Amount" :duration="3000" class="card-panel-num"  style="color: #ff0000;"/> 
          </div>
          <div class="card-panel-text" style="font-size:14px;">
            已分派：<count-to :start-val="0" :end-val="panel.exOrder2Amount" :duration="3000" class="card-panel-num" style="font-size:14px;" /> 
            <span style="margin-left:10px;"></span>
            已处理：<count-to :start-val="0" :end-val="panel.exOrder3Amount" :duration="3000" class="card-panel-num" style="font-size:14px;" /> 
          </div>          
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import CountTo from 'vue-count-to'
import { getPanegroups} from "@/api/index";
export default {
  components: {
    CountTo
  },
  data() { 
    return {
      panel: {},
      roles: null
    }
  },
  created() {
    this.getPanegroups();
    this.roles = this.$store.getters.roles;
  },
  methods: {
    handleSetLineChartData(type) {
      this.$emit('handleSetLineChartData', type)
    },
    getPanegroups(){
      getPanegroups().then(res=>{
        this.panel = res.data;
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: 0px;

  .card-panel-col {
    margin-bottom: 10px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      // padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 90px;
    }

    .card-panel-description {
      // float: right;
      font-weight: bold;
      margin: 30px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
